<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品信息</title>
<%@ include file="../../header_inc.jsp"%>
	<script type="text/javascript" src="${ctx}/js/other.js"></script>

</head>
 <style type="text/css" media="screen">
 	.btn
	{
    	border-right: #63B8FF 1px solid;
   		padding-right: 2px;
    	border-top: #63B8FF 1px solid;
    	padding-left: 2px;
    	font-size: 12px;
    	FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,  StartColorStr=#ffffff,  EndColorStr=#C3DAF5);
    	border-left: #63B8FF 1px solid;
    	cursor: hand;
    	color: black;
    	padding-top: 2px;
    	border-bottom: #63B8FF 1px solid;

	}
 	
 	</style>
<body class="easyui-layout">
		 <div data-options="region:'north',border:false"
		style="height: 0px; background: #EEEEEE; padding: 5px">
		
		<form id="formModule" method="post">


			餐品名：<input id="names" maxlength="10"
				onchange="searchit();" class="easyui-validatebox textbox"
				type="text" name="names" style="width: 120px"></input> &nbsp; 
			</select> &nbsp; 
		              价格&nbsp;>=&nbsp;<input id="price"
				maxlength="10" onchange="searchit();" onkeyup="value=value.replace(/[^1234567890.]+/g,'')"
				class="easyui-validatebox textbox" type="text" name="_price"
				style="width: 70px"></input>&nbsp;<= &nbsp;<input id="price"
				maxlength="10" onchange="searchit();" onkeyup="value=value.replace(/[^1234567890.]+/g,'')"
				class="easyui-validatebox textbox" type="text" name="price_"
				style="width: 70px"></input>
				&nbsp;&nbsp;
                <a href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-search',plain:true" onclick="searchit()">查询</a> 

		</form>
		
		</div> 
	
	<div data-options="region:'center',title:''">
		<table id="dg" class="easyui-datagrid" title="" fit="true"
			style="width: 700px; height: 250px"
			data-options="rownumbers:true,singleSelect:false,url:'dataGrid',method:'get',toolbar:'#toolbar',fit:true,
				showFooter:false,singleSelect:false,pagination:true,idField:'commodityId'">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true">全选</th>
					<!--  <th data-options="field:'custId',width:180,align:'center'">编号</th>
				<th data-options="field:'_operate1',width:60,align:'center'">详细资料</th>-->
					<th data-options="field:'names',width:100,align:'center'">商品名称</th>
					<th data-options="field:'commodityCategory',width:100,formatter:showCategory">商品类别</th>
					 <th data-options="field:'photo',width:180,align:'center'">图片</th> 
					<th data-options="field:'nativePrice',width:70,align:'center'">原价</th>
					<th data-options="field:'price',width:70,align:'center'">价格</th>
				    <th data-options="field:'number',width:70,align:'center'">库存</th>
					<th data-options="field:'viewCount',width:70,align:'center'">浏览</th>
					<th data-options="field:'orderCount',width:70,align:'center'">订单数</th>
					<th data-options="field:'createTime',width:150,align:'center',formatter:formatDate">创建时间</th>
					<th data-options="field:'status',width:70,align:'center',formatter:showStatus">状态</th>
					<!-- <th data-options="field:'_operate',width:150,align:'center',formatter:formatOper">操作</th> -->
				</tr>
			</thead>
		</table>
		<div id="toolbar" style="height: auto">
		${buttons } 
		</div> 
<script type="text/javascript">
		 $(document).ready(function(){
					
			/*  $("#depId").combobox({
	            	onChange: function (n,o) {
	            		searchit();
	          		}
	           	}) */
	    			
				 
				 //获取当前用户可查看到的部门
				/* showDataInCombotree('${ctx }/manage/sysDepartment/getAllDepaetment?flag=2',$("#depId"),'${model.sysDepartment.depId}'); */
				  });  
			 
			 
				function append() {
					var params = {
		    	                winId:'win_adds_sysCustomerss',
		    	                title:'添加商品信息',
		    	                width:370,
		    	                height:380,
		    	                showUrl:'${ctx}/manage/commodity/add',
		    	                refresh_fun:function(){
		    	                	$('#dg').datagrid('uncheckAll');
		    	                    $('#dg').datagrid('reload');
		    	                }
		    	                
		    	        };
		    	        open_fun(params);
				}

				function edit() {
					 	var id=0;
		                var row = $('#dg').datagrid('getSelected');
		            	//var row = $('#dg').datagrid('getSelections');
		            	var len = $('#dg').datagrid('getSelections').length; 
		            	
		               	if(len>1){
		               		$.messager.alert("提示","只能选择一个进行更改!");
		               	}
		               	else if(len==1 && row)
		                {
		                    id = row.commodityId;
		                    name = row.names;
		                        //winId,title,width,height,showUrl,okUrl,refresh_fun
		                        var params = {
		                                winId:'win_edit_syscustomer',
		                                title:'修改 商品'+name,
		                                width:450,
		                                height:380,
		                                showUrl:'${ctx}/manage/commodity/edit?id='+id,
		                                refresh_fun:function(){
		                                	$('#dg').datagrid('uncheckAll');
		                                    $('#dg').datagrid('reload');
		                                }
		                                
		                        };
		                        open_fun(params);   
		                    
		                }           
		                else
		                {
		                    $.messager.alert("提示","请选择要修改的信息!");
		                }
				}

				function removeit() {
					var ids = [];
		        	var rows = $('#dg').datagrid('getSelections');
		        	var len = $('#dg').datagrid('getSelections').length; 
		        	for(var i=0; i<rows.length; i++){
		        		ids.push(rows[i].commodityId);
		        	}
		            if(!len)
		            {
		                $.messager.alert("提示","请选择要移除的数据！");
		            }
		            else
		            {
		                $.messager.confirm("移除确认","是否要移除你选择的数据？",function(conf){
		                    if(conf)
		                    {
		                        var url = "${ctx}/manage/commodity/remove?ids="+ids;
		                        $.getJSON(url, function(json){
		                            if(json.success==0)
		                            {
		                            	
		                            	$('#dg').datagrid('uncheckAll');
		                                $('#dg').datagrid('reload');
		                            }
		                            else
		                            {
		                                showErrMsg(json);
		                            }
		                        });
		                    }                                       
		                });
		            }
				}

				function deleteit() {
					var ids = [];
		        	var len = $('#dg').datagrid('getSelections').length; 
		        	var rows = $('#dg').datagrid('getSelections');
		        	for(var i=0; i<rows.length; i++){
		        		ids.push(rows[i].commodityId);
		        	}
		            if(!len)
		            {
		                $.messager.alert("提示","请选择要删除的数据！");
		            }
		            else
		            {	
		                $.messager.confirm("删除确认","是否要删除你选择的数据？",function(conf){
		                    if(conf)
		                    {	
		                        var url = "${ctx}/manage/commodity/delete?ids="+ids;
		                        $.getJSON(url, function(json){
		                            if(json.success==0)
		                            {
		                            	$('#dg').datagrid('uncheckAll');
		                                $('#dg').datagrid('reload');
		                            }
		                            else
		                            {
		                            	$.messager.alert("删除失败",json.msg);
		                            }
		                        });
		                    }                                       
		                });
		            }
				}
              	//查询
				function searchit() {
					var vals = $('#formModule').serialize();
					var url = '${ctx}//manage/commodity/dataGrid';
					$("#dg").datagrid("load", sy.serializeObject($('#formModule').form()));
				}
				
				//右侧菜单
				function formatOper(val, row, index) {
					return ' <a href="#" onclick="show_fun();"><input class="btn" type="button" value="详细" ></a> ';
				}
				
				//格式化日期
				function formatDate (strTime) {
				    var date = new Date(strTime);
				    return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
				}
				  //显示商品详细
		    	function show_fun()
		    	{
		    			var row = $('#dg').datagrid('getSelected');
		        		var id = row.commodityId;
		        		var name = row.names;
		    	       var params = {
		    	                winId:'win_showuser_sysCustomer',
		    	                title:name+'的详细资料',
		    	                width:700,
		    	                height:425,
		    	                showUrl:'${ctx}/manage/commodity/view?id='+id,
		    	                refresh_fun:function(json){
		  
		     	                	$('#dg').datagrid('uncheckAll');
		      	                    $('#dg').datagrid('reload');

		    	                }
		    	                
		    	        };
		    	       ShowUserFun(params);

		    	}			
			</script>

		</div>

	</div>
</body>
</html>